package com.longjianghuasheng.logistics.business.mine.viewmodel

import androidx.lifecycle.MutableLiveData
import com.longjianghuasheng.logistics.entity.MyInfoResponse
import com.longjianghuasheng.logistics.entity.OrderType
import com.longjianghuasheng.logistics.ext.commit
import com.longjianghuasheng.logistics.ext.commit2
import com.longjianghuasheng.logistics.network.apiService
import com.longjianghuasheng.logistics.repository.request.HttpRequestCoroutine
import com.longjianghuasheng.logistics.util.CacheUtil
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel

class MineViewModel : BaseViewModel() {

    var is_account = 0

    var avatar = ""

    var isJump = false

    val result by lazy {
        MutableLiveData<MyInfoResponse>()
    }

    val resultHot_line by lazy {
        MutableLiveData<String>()
    }

    fun my_info() {

        if (!CacheUtil.isLogin) return

        commit({ apiService.my_info() }, result, isShowDialog = false)
    }

    fun hot_line() {
        commit(
            { apiService.hot_line() },
            resultHot_line,
            isToastSuccess = false,
            isShowDialog = false
        )
    }

    fun avatar() {

        commit2({ HttpRequestCoroutine.avatar(avatar) }, success = {
            my_info()
        })
    }


}